import { Injectable } from "@angular/core";

import { ServiceDefinition, DataTypeEnum, RESTEnum, WebSocketEnum, ConfigService } from '../../../framework';
import { MockUsers } from './login.service.data';

@Injectable()
export class LoginServiceConfig{
    config: ConfigService = new ConfigService();
    constructor() {
    }

    LoginMS(): ServiceDefinition {
        let configuration: ServiceDefinition = new ServiceDefinition();
        configuration.dataType = DataTypeEnum.mock;
        configuration.mockData = MockUsers;
        configuration.serviceConfig = null;
        return configuration;
    }

    LoginRS(): ServiceDefinition {
        let configuration: ServiceDefinition = new ServiceDefinition();
        let serviceUrl = this.config.getValueByKey('SERVICR_PATH');
        configuration.dataType = DataTypeEnum.RESTful;
        configuration.serviceConfig = {
            query: { method: RESTEnum.GET, serviceUrl: serviceUrl, httpHeaders:{ 'Content-Type': 'application/json' } },
            get: { method: RESTEnum.GET, serviceUrl: serviceUrl, httpHeaders:{ 'Content-Type': 'application/json' }  },
            post: { method: RESTEnum.POST, serviceUrl: serviceUrl, httpHeaders:{ 'Content-Type': 'application/json' }  },
            put: { method: RESTEnum.PUT, serviceUrl: serviceUrl, httpHeaders:{ 'Content-Type': 'application/json' }  },
            delete: { method: RESTEnum.DELETE, serviceUrl: serviceUrl  }
        };
        return configuration;
    }

    LoginWS(): ServiceDefinition {
        let configuration: ServiceDefinition = new ServiceDefinition();
        configuration.dataType = DataTypeEnum.webSockt;
        configuration.webSocketUrl = this.config.getValueByKey('WEBSOCKET_URL');
        configuration.serviceConfig = {
            put: {
                method: WebSocketEnum.publish,
                //common: { fullSQL: "", selector: '', topic: `processInfo` }
                publish:{}
            },
            delete: {
                method: WebSocketEnum.invokeProxy,
                invokeProxy: { className: "com.pingan.pilot.caps.common.proxy.ISettlementInstructionsProxy", method: "addSettlementInstructions" }
            },
            post: {
                method: WebSocketEnum.publish,
                publish: {}
            },
            query: {
                method: WebSocketEnum.query,
                common: { fullSQL: "", selector: '', topic: `processInfo` }
            },
            get: {
                method: WebSocketEnum.query,
                common: { fullSQL: "select * from msgDefinition", selector: '', topic: `processInfo` }
            },
        };
        return configuration;
    }
}